<?php 
 include_once dirname(__FILE__)."/config.php";
 class unite_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_code_ue;
		 protected $_lib_unite;
		 protected $_nature_unite;
		 protected $_ECUE;
		 protected $_volume_cours;
		 protected $_volume_TP;
		 protected $_volume_TD;
		 protected $_coeifficient;
		 protected $_code_diplome;
		 protected $_code_niveau;
		 protected $_code_domaine;
		 protected $_date_soumission;
		 protected $_credit;
		 protected $_projet;
		 protected $_CIN;
		 protected $_date_depot_contenu;
		 protected $_code_mention;
		 protected $_specialite;
		 protected $_session;
		 protected $_date_decision;
		 protected $_decision;
		 protected $_observation_ue;
		 protected $_mail_sended;
		 protected $_nbr_ens;
		 protected $_decision_production;
		 protected $_date_decision_num;
		 protected $_date_decision_exp;
		 protected $_duree;
		 protected $_delai_jour;
		 protected $_validation_scientifique;
		 protected $_expRPL;
		 protected $_expMoodle;
		 protected $_etat_soumission;
		 
		 
		 
		 public function get_name_table(){ return "unite";}
		 public function get_name_code_ue(){ return "code_ue";}
		 public function get_name_lib_unite(){ return "lib_unite";}
		 public function get_name_nature_unite(){ return "nature_unite";}
		 public function get_name_ECUE(){ return "ECUE";}
		 public function get_name_volume_cours(){ return "volume_cours";}
		 public function get_name_volume_TP(){ return "volume_TP";}
		 public function get_name_volume_TD(){ return "volume_TD";}
		 public function get_name_coeifficient(){ return "coeifficient";}
		 public function get_name_code_diplome(){ return "code_diplome";}
		 public function get_name_code_niveau(){ return "code_niveau";}
		 public function get_name_code_domaine(){ return "code_domaine";}
		 public function get_name_date_soumission(){ return "date_soumission";}
		 public function get_name_credit(){ return "credit";}
		 public function get_name_projet(){ return "projet";}
		 public function get_name_CIN(){ return "CIN";}
		 public function get_name_date_depot_contenu(){ return "date_depot_contenu";}
		 public function get_name_code_mention(){ return "code_mention";}
		 public function get_name_specialite(){ return "specialite";}
		 public function get_name_session(){ return "session";}
		 public function get_name_date_decision(){ return "date_decision";}
		 public function get_name_decision(){ return "decision";}
		 public function get_name_observation_ue(){ return "observation_ue";}
		 public function get_name_mail_sended(){ return "mail_sended";}
		 public function get_name_nbr_ens(){ return "nbr_ens";}
		 public function get_name_decision_production(){ return "decision_production";}
		 public function get_name_date_decision_num(){ return "date_decision_num";}
		 public function get_name_date_decision_exp(){ return "date_decision_exp";}
		 public function get_name_duree(){ return "duree";}
		 public function get_name_delai_jour(){ return "delai_jour";}
		 public function get_name_validation_scientifique(){ return "validation_scientifique";}
		 public function get_name_expRPL(){ return "expRPL";}
		 public function get_name_expMoodle(){ return "expMoodle";}
		 public function get_name_etat_soumission(){ return "etat_soumission";}
		 
		 
		 public function set_code_ue($parametre){  $this->_code_ue=$parametre;}	
		 public function set_lib_unite($parametre){  $this->_lib_unite=$parametre;}	
		 public function set_nature_unite($parametre){  $this->_nature_unite=$parametre;}	
		 public function set_ECUE($parametre){  $this->_ECUE=$parametre;}	
		 public function set_volume_cours($parametre){  $this->_volume_cours=$parametre;}	
		 public function set_volume_TP($parametre){  $this->_volume_TP=$parametre;}	
		 public function set_volume_TD($parametre){  $this->_volume_TD=$parametre;}	
		 public function set_coeifficient($parametre){  $this->_coeifficient=$parametre;}	
		 public function set_code_diplome($parametre){  $this->_code_diplome=$parametre;}	
		 public function set_code_niveau($parametre){  $this->_code_niveau=$parametre;}	
		 public function set_code_domaine($parametre){  $this->_code_domaine=$parametre;}	
		 public function set_date_soumission($parametre){  $this->_date_soumission=$parametre;}	
		 public function set_credit($parametre){  $this->_credit=$parametre;}	
		 public function set_projet($parametre){  $this->_projet=$parametre;}	
		 public function set_CIN($parametre){  $this->_CIN=$parametre;}	
		 public function set_date_depot_contenu($parametre){  $this->_date_depot_contenu=$parametre;}	
		 public function set_code_mention($parametre){  $this->_code_mention=$parametre;}	
		 public function set_specialite($parametre){  $this->_specialite=$parametre;}	
		 public function set_session($parametre){  $this->_session=$parametre;}	
		 public function set_date_decision($parametre){  $this->_date_decision=$parametre;}	
		 public function set_decision($parametre){  $this->_decision=$parametre;}	
		 public function set_observation_ue($parametre){  $this->_observation_ue=$parametre;}	
		 public function set_mail_sended($parametre){  $this->_mail_sended=$parametre;}	
		 public function set_nbr_ens($parametre){  $this->_nbr_ens=$parametre;}	
		 public function set_decision_production($parametre){  $this->_decision_production=$parametre;}	
		 public function set_date_decision_num($parametre){  $this->_date_decision_num=$parametre;}	
		 public function set_date_decision_exp($parametre){  $this->_date_decision_exp=$parametre;}	
		 public function set_duree($parametre){  $this->_duree=$parametre;}	
		 public function set_delai_jour($parametre){  $this->_delai_jour=$parametre;}	
		 public function set_validation_scientifique($parametre){  $this->_validation_scientifique=$parametre;}	
		 public function set_expRPL($parametre){  $this->_expRPL=$parametre;}	
		 public function set_expMoodle($parametre){  $this->_expMoodle=$parametre;}
		 public function set_etat_soumission($parametre){  $this->_etat_soumission=$parametre;}
		 
		 
		 	
		 public function get_result(){ return $this->_result;}
		 public function get_code_ue(){ return $this->_code_ue;}
		 public function get_lib_unite(){ return $this->_lib_unite;}
		 public function get_nature_unite(){ return $this->_nature_unite;}
		 public function get_ECUE(){ return $this->_ECUE;}
		 public function get_volume_cours(){ return $this->_volume_cours;}
		 public function get_volume_TP(){ return $this->_volume_TP;}
		 public function get_volume_TD(){ return $this->_volume_TD;}
		 public function get_coeifficient(){ return $this->_coeifficient;}
		 public function get_code_diplome(){ return $this->_code_diplome;}
		 public function get_code_niveau(){ return $this->_code_niveau;}
		 public function get_code_domaine(){ return $this->_code_domaine;}
		 public function get_date_soumission(){ return $this->_date_soumission;}
		 public function get_credit(){ return $this->_credit;}
		 public function get_projet(){ return $this->_projet;}
		 public function get_CIN(){ return $this->_CIN;}
		 public function get_date_depot_contenu(){ return $this->_date_depot_contenu;}
		 public function get_code_mention(){ return $this->_code_mention;}
		 public function get_specialite(){ return $this->_specialite;}
		 public function get_session(){ return $this->_session;}
		 public function get_date_decision(){ return $this->_date_decision;}
		 public function get_decision(){ return $this->_decision;}
		 public function get_observation_ue(){ return $this->_observation_ue;}
		 public function get_mail_sended(){ return $this->_mail_sended;}
		 public function get_nbr_ens(){ return $this->_nbr_ens;}
		 public function get_decision_production(){ return $this->_decision_production;}
		 public function get_date_decision_num(){ return $this->_date_decision_num;}
		 public function get_date_decision_exp(){ return $this->_date_decision_exp;}
		 public function get_duree(){ return $this->_duree;}
		 public function get_delai_jour(){ return $this->_delai_jour;}
		 public function get_validation_scientifique(){ return $this->_validation_scientifique;}
		 public function get_expRPL(){ return $this->_expRPL;}
		 public function get_expMoodle(){ return $this->_expMoodle;}
		 public function get_etat_soumission(){ return $this->_etat_soumission;}
		 
		 
		 
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 unite(
			lib_unite,
			nature_unite,
			ECUE,
			volume_cours,
			volume_TP,
			volume_TD,
			coeifficient,
			code_diplome,
			code_niveau,
			code_domaine,
			date_soumission,
			credit,
			projet,
			CIN,
			date_depot_contenu,
			code_mention,
			specialite,
			session,
			date_decision,
			decision,
			observation_ue,
			mail_sended,
			nbr_ens,
			decision_production,
			date_decision_num,
			date_decision_exp,
			duree,
			delai_jour,
			validation_scientifique,
			expRPL,
			expMoodle,
			etat_soumission)
 VALUES(
			'".$this->_lib_unite."',
			'".$this->_nature_unite."',
			'".$this->_ECUE."',
			'".$this->_volume_cours."',
			'".$this->_volume_TP."',
			'".$this->_volume_TD."',
			'".$this->_coeifficient."',
			'".$this->_code_diplome."',
			'".$this->_code_niveau."',
			'".$this->_code_domaine."',
			'".$this->_date_soumission."',
			'".$this->_credit."',
			'".$this->_projet."',
			'".$this->_CIN."',
			'".$this->_date_depot_contenu."',
			'".$this->_code_mention."',
			'".$this->_specialite."',
			'".$this->_session."',
			'".$this->_date_decision."',
			'".$this->_decision."',
			'".$this->_observation_ue."',
			'".$this->_mail_sended."',
			'".$this->_nbr_ens."',
			'".$this->_decision_production."',
			'".$this->_date_decision_num."',
			'".$this->_date_decision_exp."',
			'".$this->_duree."',
			'".$this->_delai_jour."',
			'".$this->_validation_scientifique."',
			'".$this->_expRPL."',
			'".$this->_expMoodle."',
			'".$this->_etat_soumission."'
			
			)";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="etat_soumission='1'";
 
 
if(!empty($this->_lib_unite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
lib_unite='".$this->_lib_unite."'";
}
if(!empty($this->_nature_unite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
nature_unite='".$this->_nature_unite."'";
}
if(!empty($this->_ECUE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
ECUE='".$this->_ECUE."'";
}
if(!empty($this->_volume_cours)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
volume_cours='".$this->_volume_cours."'";
}
if(!empty($this->_volume_TP)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
volume_TP='".$this->_volume_TP."'";
}
if(!empty($this->_volume_TD)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
volume_TD='".$this->_volume_TD."'";
}
if(!empty($this->_coeifficient)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
coeifficient='".$this->_coeifficient."'";
}
if(!empty($this->_code_diplome)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_diplome='".$this->_code_diplome."'";
}
if(!empty($this->_code_niveau)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_niveau='".$this->_code_niveau."'";
}
if(!empty($this->_code_domaine)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_domaine='".$this->_code_domaine."'";
}
if(!empty($this->_date_soumission)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_soumission='".$this->_date_soumission."'";
}
if(!empty($this->_credit)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
credit='".$this->_credit."'";
}
if(!empty($this->_projet)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
projet='".$this->_projet."'";
}
if(!empty($this->_CIN)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CIN='".$this->_CIN."'";
}
if(!empty($this->_date_depot_contenu)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_depot_contenu='".$this->_date_depot_contenu."'";
}
if(!empty($this->_code_mention)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_mention='".$this->_code_mention."'";
}
if(!empty($this->_specialite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
specialite='".$this->_specialite."'";
}
if(!empty($this->_session)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
session='".$this->_session."'";
}
if(!empty($this->_date_decision)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_decision='".$this->_date_decision."'";
}
if(!empty($this->_decision)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
decision='".$this->_decision."'";
}
if(!empty($this->_observation_ue)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
observation_ue='".$this->_observation_ue."'";
}
if(!empty($this->_mail_sended)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
mail_sended='".$this->_mail_sended."'";
}
if(!empty($this->_nbr_ens)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
nbr_ens='".$this->_nbr_ens."'";
}
if(!empty($this->_decision_production)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
decision_production='".$this->_decision_production."'";
}
if(!empty($this->_date_decision_num)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_decision_num='".$this->_date_decision_num."'";
}
if(!empty($this->_date_decision_exp)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_decision_exp='".$this->_date_decision_exp."'";
}
if(!empty($this->_duree)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
duree='".$this->_duree."'";
}
if(!empty($this->_delai_jour)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
delai_jour='".$this->_delai_jour."'";
}
if(!empty($this->_validation_scientifique)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
validation_scientifique='".$this->_validation_scientifique."'";
}
if(!empty($this->_expRPL)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
expRPL='".$this->_expRPL."'";
}
if(!empty($this->_expMoodle)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
expMoodle='".$this->_expMoodle."'";
}
if(!empty($this->_etat_soumission)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
etat_soumission='1'";
}



$sql="UPDATE 
unite SET 
 ".$sql."
								WHERE code_ue ='".$this->_code_ue."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

public function UPDATE1()
{

 $sql="";
 
 
if(!empty($this->_lib_unite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
lib_unite='".$this->_lib_unite."'";
}
if(!empty($this->_nature_unite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
nature_unite='".$this->_nature_unite."'";
}
if(!empty($this->_ECUE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
ECUE='".$this->_ECUE."'";
}
if(!empty($this->_volume_cours)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
volume_cours='".$this->_volume_cours."'";
}
if(!empty($this->_volume_TP)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
volume_TP='".$this->_volume_TP."'";
}
if(!empty($this->_volume_TD)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
volume_TD='".$this->_volume_TD."'";
}
if(!empty($this->_coeifficient)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
coeifficient='".$this->_coeifficient."'";
}
if(!empty($this->_code_diplome)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_diplome='".$this->_code_diplome."'";
}
if(!empty($this->_code_niveau)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_niveau='".$this->_code_niveau."'";
}
if(!empty($this->_code_domaine)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_domaine='".$this->_code_domaine."'";
}
if(!empty($this->_date_soumission)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_soumission='".$this->_date_soumission."'";
}
if(!empty($this->_credit)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
credit='".$this->_credit."'";
}
if(!empty($this->_projet)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
projet='".$this->_projet."'";
}
if(!empty($this->_CIN)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CIN='".$this->_CIN."'";
}
if(!empty($this->_date_depot_contenu)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_depot_contenu='".$this->_date_depot_contenu."'";
}
if(!empty($this->_code_mention)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_mention='".$this->_code_mention."'";
}
if(!empty($this->_specialite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
specialite='".$this->_specialite."'";
}
if(!empty($this->_session)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
session='".$this->_session."'";
}
if(!empty($this->_date_decision)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_decision='".$this->_date_decision."'";
}
if(!empty($this->_decision)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
decision='".$this->_decision."'";
}
if(!empty($this->_observation_ue)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
observation_ue='".$this->_observation_ue."'";
}
if(!empty($this->_mail_sended)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
mail_sended='".$this->_mail_sended."'";
}
if(!empty($this->_nbr_ens)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
nbr_ens='".$this->_nbr_ens."'";
}
if(!empty($this->_decision_production)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
decision_production='".$this->_decision_production."'";
}
if(!empty($this->_date_decision_num)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_decision_num='".$this->_date_decision_num."'";
}
if(!empty($this->_date_decision_exp)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_decision_exp='".$this->_date_decision_exp."'";
}
if(!empty($this->_duree)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
duree='".$this->_duree."'";
}
if(!empty($this->_delai_jour)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
delai_jour='".$this->_delai_jour."'";
}
if(!empty($this->_validation_scientifique)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
validation_scientifique='".$this->_validation_scientifique."'";
}
if(!empty($this->_expRPL)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
expRPL='".$this->_expRPL."'";
}
if(!empty($this->_expMoodle)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
expMoodle='".$this->_expMoodle."'";
}
if(!empty($this->_etat_soumission)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
etat_soumission='".$this->_etat_soumission."'";
}



$sql="UPDATE 
unite SET 
 ".$sql."
								WHERE code_ue ='".$this->_code_ue."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}


 public function DELETE(){

 $sql="DELETE FROM 
unite 
 
									WHERE code_ue ='".$this->_code_ue."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}


 public function TRANCATE(){

 $sql="DELETE FROM 
unite ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		code_ue,
		lib_unite,
		nature_unite,
		ECUE,
		volume_cours,
		volume_TP,
		volume_TD,
		coeifficient,
		code_diplome,
		code_niveau,
		code_domaine,
		date_soumission,
		credit,
		projet,
		CIN,
		date_depot_contenu,
		code_mention,
		specialite,
		session,
		date_decision,
		decision,
		observation_ue,
		mail_sended,
		nbr_ens,
		decision_production,
		date_decision_num,
		date_decision_exp,
		duree,
		delai_jour,
		validation_scientifique,
		expRPL,
		expMoodle,
		etat_soumission
 FROM 
 unite";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}
if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_code_ue=$row->code_ue;
		$this->_lib_unite=$row->lib_unite;
		$this->_nature_unite=$row->nature_unite;
		$this->_ECUE=$row->ECUE;
		$this->_volume_cours=$row->volume_cours;
		$this->_volume_TP=$row->volume_TP;
		$this->_volume_TD=$row->volume_TD;
		$this->_coeifficient=$row->coeifficient;
		$this->_code_diplome=$row->code_diplome;
		$this->_code_niveau=$row->code_niveau;
		$this->_code_domaine=$row->code_domaine;
		$this->_date_soumission=$row->date_soumission;
		$this->_credit=$row->credit;
		$this->_projet=$row->projet;
		$this->_CIN=$row->CIN;
		$this->_date_depot_contenu=$row->date_depot_contenu;
		$this->_code_mention=$row->code_mention;
		$this->_specialite=$row->specialite;
		$this->_session=$row->session;
		$this->_date_decision=$row->date_decision;
		$this->_decision=$row->decision;
		$this->_observation_ue=$row->observation_ue;
		$this->_mail_sended=$row->mail_sended;
		$this->_nbr_ens=$row->nbr_ens;
		$this->_decision_production=$row->decision_production;
		$this->_date_decision_num=$row->date_decision_num;
		$this->_date_decision_exp=$row->date_decision_exp;
		$this->_duree=$row->duree;
		$this->_delai_jour=$row->delai_jour;
		$this->_validation_scientifique=$row->validation_scientifique;
		$this->_expRPL=$row->expRPL;
		$this->_expMoodle=$row->expMoodle;
		$this->_etat_soumission=$row->etat_soumission;
		
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>